package com.xgz.aspect;

import com.xgz.service.aop.Aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 切面
 * @author xgz
 */
@Aspect
@Component
public class XgzAspect {

	// 切入点
	@Pointcut("@annotation(com.xgz.aspect.anno.LogSys)")
	public void LogPoint(){

	}

	// 对 Aop 类的 aopMethod 方法进行增强
	@Before("execution(public void com.xgz.service.aop.Aop.aopMethod())")
	public void  aopClassAdvise(JoinPoint joinPoint){
		Aop target = (Aop) joinPoint.getTarget();
		Aop aThis = (Aop) joinPoint.getThis();
		System.out.println("target:" + target);
		System.out.println("aThis:" + aThis);
		System.out.println("切面逻辑结束！");
	}

	// 对 C 类的 cMethod 方法进行前置增强
	@Before("execution(public void com.xgz.service.aopcircular.C.cMethod())")
	public void  cClassBefore(JoinPoint joinPoint){
		System.out.println("cMethod 前置增强 ...");
	}

	// 对 C 类的 cMethod 方法进行后置增强
	@After(value = "LogPoint()")
	public void  cClassAfter(JoinPoint joinPoint){
		System.out.println("注解 后置增强 ...");
	}
}
